package cn.tannn.cat.file.server.controller;

import cn.tannn.cat.file.server.init.LocalInitDynamicResourceHandlerManager;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

/**
 *  管理界面
 *
 * @author <a href="https://tannn.cn/">tan</a>
 * @date 2024/3/7 11:16
 */
@Controller
public class HiController {

    private final LocalInitDynamicResourceHandlerManager localInitDynamicResourceHandlerManager;

    public HiController(LocalInitDynamicResourceHandlerManager localInitDynamicResourceHandlerManager) {
        this.localInitDynamicResourceHandlerManager = localInitDynamicResourceHandlerManager;
    }

    @GetMapping("/admin")
    public String index() {
        return "/index";
    }


    /**
     * 获取所有资源处理器
     */
    @GetMapping("/rh")
    public ResponseEntity<Map<String, String>> listResourceHandlers() {
        return ResponseEntity.ok(localInitDynamicResourceHandlerManager.getAllResourceHandlers());
    }
}
